﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	mc:Ignorable="d"
	x:Class="Faust.Andrew.MTG.Player.ControlBox"
	x:Name="UserControl" MaxWidth="182">
	<UserControl.Resources>
		<ItemsPanelTemplate x:Key="TokenItemPanel">
			<WrapPanel IsItemsHost="True"/>
		</ItemsPanelTemplate>
		<DataTemplate x:Key="TokenItemTemplate">
			<Grid>
				<Button HorizontalAlignment="Left" Width="Auto" d:LayoutOverrides="Height" ToolTip="{Binding ModifierText, Mode=OneWay}" Click="AddExistingToken_Click">
					<Image Height="Auto" Source="images\Preppy.png" Width="24"/>
				</Button>
			</Grid>
		</DataTemplate>
		<DataTemplate x:Key="CounterItemTemplate">
			<Grid PreviewMouseLeftButtonDown="Counter_PreviewMouseLeftButtonDown" PreviewMouseMove="Counter_PreviewMouseMove">
				<Image Source="images/counter.png" Width="30" Panel.ZIndex="1"></Image>
				<Label Margin="0" Content="{Binding Value, Mode=OneWay}" d:LayoutOverrides="Width, Height" VerticalAlignment="Center" HorizontalAlignment="Center" ToolTip="{Binding Name, Mode=OneWay}" Panel.ZIndex="2"/>
				<Ellipse HorizontalAlignment="Center" VerticalAlignment="Center" Width="25" Height="25" Fill="{Binding Color, Converter={StaticResource ColorToBrushConverter}, Mode=OneWay}"/>
			</Grid>
		</DataTemplate>
	</UserControl.Resources>	
	<StackPanel>
		<StackPanel Orientation="Horizontal" Margin="0,0,0,5">
			<Button x:Name="btnEndTurn" Margin="0,0,10,0" Click="btnEndTurn_Click" ToolTip="End Turn">
				<Image Source="images\Knob Valid Blue.png" Width="32"/>
			</Button>
			<Button x:Name="btnTokenCreature" Margin="0,0,10,0" Click="btnTokenCreature_Click" ToolTip="Add Creature Tokens"><Image Source="images\User Group.png" ToolTip="Play Creature Token" Width="32" /></Button>
			<Button x:Name="btnRollDie" Click="btnRollDie_Click" ToolTip="Roll Die" Margin="0,0,10,0"><Image Source="images\Dice-1-32x32.png" ToolTip="Roll Dice" /></Button>
			<Button x:Name="btnUntapAll" Click="btnUntapAll_Click">
				<Image Source="images\Knob Loop On.png" Width="32"/>
			</Button>
		</StackPanel>
		<StackPanel Margin="0,0,0,5">
			<Grid Width="182" Height="25.96" Margin="0,0,0,2">
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="0.495*"/>
					<ColumnDefinition Width="0.505*"/>
				</Grid.ColumnDefinitions>
				<Label Content="Counters" Foreground="White" d:LayoutOverrides="Width, Height" Margin="0"/>
				<Button x:Name="btnNewCounter" Margin="0" Grid.Column="1" Click="btnNewCounter_Click" HorizontalAlignment="Right" VerticalAlignment="Center">
					<Image Source="images/Knob Add.png" ToolTip="Add New Counter Type" Visibility="Collapsed"/>
				</Button>
			</Grid>
			<ItemsControl ItemsPanel="{DynamicResource TokenItemPanel}" ItemsSource="{Binding Presenter.Model.AdditionCounters, ElementName=UserControl, Mode=Default}" ItemTemplate="{DynamicResource CounterItemTemplate}"/>
			<ItemsControl ItemsPanel="{DynamicResource TokenItemPanel}" ItemsSource="{Binding Presenter.Model.SubtractionCounters, ElementName=UserControl, Mode=Default}" ItemTemplate="{DynamicResource CounterItemTemplate}"/>
		</StackPanel>
		<StackPanel>
			<Label Content="Tokens" Foreground="White" Margin="0,0,0,2"/>
			<ItemsControl ItemsSource="{Binding Presenter.Model.Tokens, ElementName=UserControl, Mode=OneWay}" ItemsPanel="{DynamicResource TokenItemPanel}" ItemTemplate="{DynamicResource TokenItemTemplate}"/>
		</StackPanel>
	</StackPanel>
</UserControl>